import ShareUtil from "./ShareUtil";
import LocalResources from "../../GMDCocosBase/LocalResources";
import FB from "../FB";

//广播管理器
export default class BroadcastMgr
{
    //title广播内容
    //img 广播的图片编号
    public static PostMsg(title:string,img:number)
    {
        var imgBase64 = ShareUtil.getImgBase64(
            LocalResources.Singletion.GetRes( img ).getTexture() 
            )
        FB.updateAsync({
            action: 'CUSTOM',
            cta: '',//Join The Fight
            image: imgBase64,
            text: {
                default: title,
                localizations: {
                //  ar_AR: 'X \u0641\u0642\u0637 \u063A\u0632\u062A ' +                '\u0642\u0631\u064A\u0629 Y!',
                //en_US: 'X just invaded Y\'s village!',
                //es_LA: '\u00A1X acaba de invadir el pueblo de Y!',
                }
            },
            template: 'VILLAGE_INVASION',
            data: {},
            strategy: 'IMMEDIATE',
            notification: 'NO_PUSH',
            }).then(()=> {
                console.log("BroadcastMgr.PostMsg success",title)
            }).catch(
                ()=>{
                    console.log("BroadcastMgr.PostMsg failed",title)
                }
            )
    }

     
}